import { useRoute } from 'vue-router'
import { routeMode } from '@jsjn/micro-core-micro-main/routeMode'

type BaseList = {
    authCode: string
    [k: string]: any
}[]

export default (list: BaseList) => {
    if (routeMode !== 'backEnd') return list

    const route = useRoute()
    const btns = route.meta.btns as any[]

    return list.filter((item) => {
        const target = btns?.find((btn) => btn.perms === item.authCode)
        return target ? target.btnCheck : true
    })
}
